<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/web-frame/element/js/vue.js"></script>
</head>
<body>
<div id="app">
    <h>点击示例1</h>
    <div id="basic-event">
        <button @click="counter += 1">Add 1</button>
        <p>The button above has been clicked {{ counter }} times.</p>
    </div>

    <hr>
    <h2>事件处理方法</h2>
    <div id="event-with-method">
        <!-- `greet` 是在下面定义的方法名 -->
        <button @click="greet">Greet</button>
    </div>

    <hr>

    <h2>事件处理方法带参数</h2>
    <div id="inline-handler">
        <button @click="say('hi')">say('hi')</button>
        <button @click="say('what')">say('what')</button>
    </div>

</div>
<script>
    var Main = {
        data() {
            return {
                counter: 0,
                name: 'Vue.js'
            }
        },
        created(){

        },
        methods: {
            greet(event) {
                // `methods` 内部的 `this` 指向当前活动实例
                alert('Hello ' + this.name + '!')
                // `event` 是原生 DOM event
                if (event) {
                    alert(event.target.tagName)
                }
            },
            say(message) {
                alert(message)
            }
        },
        computed: {

        }
    }
    var Ctor = Vue.extend(Main)
    new Ctor().$mount('#app')
</script>
</body>
</html>